package com.eight.homepage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.common.pojo.TbZoneCourse;
import com.eight.common.pojo.ZoneCourse;
import com.eight.common.vo.Result;
import com.eight.homepage.service.ZoneCourseService;
import com.eight.homepage.vo.ZoneVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 向文豪
 * @program: eight-education-parent
 * @description:
 * @date 2023/5/29 18:53
 */
@RestController
@RequestMapping("/home/zone-course")
@Api(tags = "专区课程")
public class ZoneCourseController {

    @Autowired
    private ZoneCourseService zoneCourseService;

    @PostMapping("/getAllDetail/{currentPage}/{pageSize}")
    @ApiOperation("专区课程")
    public Result getAllDetail(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody ZoneVo zoneVo){

        Page<ZoneCourse> page = zoneCourseService.findPage(currentPage,pageSize,zoneVo);
        return Result.success(page);
    }

    @ApiOperation("删除专区课程")
    @PostMapping("/deleteZoneCourse")
    public Result deleteZoneCourse(@RequestBody ZoneCourse zoneCourse){
        int i = zoneCourseService.delete(zoneCourse.getId());
        return Result.success();
    }

    @ApiOperation("修改专区课程状态")
    @PostMapping("/changeStatus/{zcId}/{tzcisDisable}")
    public Result changeStatus(@PathVariable String zcId,@PathVariable Integer tzcisDisable){

       int i =  zoneCourseService.updateStatus(zcId,tzcisDisable);
       return Result.success();
    }

    @ApiOperation("课程名称查询")
    @PostMapping("/findCourse/{currentPage}/{pagerSize}")
    public Result findCourse(@PathVariable Integer currentPage,
                             @PathVariable Integer pagerSize,
                             @RequestBody ZoneVo zoneVo){
        Page<ZoneCourse> coursePage = zoneCourseService.findCoursePage(currentPage, pagerSize, zoneVo);
        return Result.success(coursePage);
    }

    @ApiOperation("添加专区课程")
    @PostMapping("/addCourseDetail")
    public  Result addCourse(@RequestBody TbZoneCourse tbZoneCourse){
        int i = zoneCourseService.addCourse(tbZoneCourse);
        return Result.success();
    }
}
